odoo.define('etc.img_url', function (require) {
    "use strict";
var core = require('web.core');
var _lt = core._lt;
    var InputField = require('web.basic_fields').InputField;
    var ImgUrl = InputField.extend({
        description: _lt("ImgUrl"),
        className: 'o_field_img_url',
        events: _.extend({}, InputField.prototype.events, {
            'click': '_onClick',
        }),
        supportedFieldTypes: ['char'],

        init: function () {
            this._super.apply(this, arguments);
            this.tagName = this.mode === 'readonly' ? 'a' : 'input';
        },

        getFocusableElement: function () {
            return this.mode === 'readonly' ? this.$el : this._super.apply(this, arguments);
        },

        _renderReadonly: function () {
            this.$el.text(this.attrs.text || this.value)
                .addClass('o_form_uri o_text_overflow')
                .attr('target', '_blank')
                .attr('href', this.value)
                .text('图片');
        },

        _onClick: function (ev) {
            ev.stopPropagation();
        },
    });

    var fieldRegistry = require('web.field_registry');
    fieldRegistry.add('img_url', ImgUrl);
    return ImgUrl
});

